﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMSSyncData.Model;
using WMSSyncData.Model.WMSModel;
using WMSSyncData.Utils;

namespace WMSSyncData.DAL.SqlDB
{
    public class WMS_T_RequestDAL : BaseSqlDBDAL<WMS_T_Request>
    {
        public List<WMS_T_Request> GetAllUpdate()
        {
            string sql = @"SELECT * FROM dbo.wms_T_Request WHERE Status='1'";
            var dt = SqlDBHelper.GetDataSet(sql).Tables[0];
            var result = MakeTablePackage(dt);
            return result;

        }

        public bool UpdateUploadStatus(List<tddev110> list)
        {
            var result = false;
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("begin");
            foreach (var item in list)
            {
                var sql = "UPDATE wms_T_Request set  Status='9' where BillNo='" + item.WMSNO + "';";
                sb.AppendLine(sql);
            }
            sb.AppendLine("end;");

            var resultSql = sb.ToString().Trim();
            var updateRes = SqlDBHelper.ExcuteSQL(resultSql);
            if (updateRes > 0)
            {
                result = true;
            }
            return result;

        }
    }
}
